<?php

include('Classes/Connect.php');
global $dbSingleton;

$event_id = $_POST['event_id'];
$agenda_id = $_POST['agenda_id'];
$isAllowedToReattribute = 0;
if (ctype_alnum($event_id) && is_numeric($agenda_id)) {
    $prestation_id = $dbSingleton->query('SELECT prestation_id FROM msa_slotobject WHERE event_id="' . $event_id . '"');
    if (is_object($prestation_id)) {
        $prestation_id->setFetchMode(PDO::FETCH_OBJ);
        $prestation_id = $prestation_id->fetch();
        $prestation_id = $prestation_id->prestation_id;
        $prestation = $dbSingleton->query('SELECT prestation FROM msa_agendaobject WHERE id=' . $agenda_id);
        if (is_object($prestation)) {
            $prestation->setFetchMode(PDO::FETCH_OBJ);
            $prestation = $prestation->fetch();
            $prestation = explode('§', $prestation->prestation);
            if (in_array($prestation_id, $prestation)) {
                $isAllowedToReattribute = 1;
            }
        }
    }
}
echo $isAllowedToReattribute;